#include<iostream>


class sigleton{
  public:
    static sigleton* GetInstance();
    void printf(){
      std::cout<<"i am lazy man"<<std::endl;
    }
  private:
    static sigleton* st;
    sigleton(){};
  static pthread_mutex_t lock;

};
pthread_mutex_t sigleton::lock=PTHREAD_MUTEX_INITIALIZER;
sigleton*sigleton::st=NULL;
sigleton*sigleton::GetInstance(){
  if(st==NULL){
    pthread_mutex_lock(&lock);
  if(st==NULL){

  st=new sigleton;
  }
  pthread_mutex_unlock(&lock);
  }
  return st;
};
int main(){
  sigleton*st=sigleton::GetInstance();
  
}


#if 0
class sigleton{
  public:
    static sigleton* GetInstance();
    void printf(){
      std::cout<<"i am lazy man"<<std::endl;
    }
  private:
    static sigleton* st;
    sigleton(){};


};
sigleton*sigleton::st=new sigleton;
sigleton*sigleton::GetInstance(){
  return st;
};

int main(){
  sigleton* st=sigleton::GetInstance();
  st->printf();
}
#endif
